package com.jfree.controller;

import com.jfree.source.TestMessageSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/test")
public class TestController {

    @Autowired
    private TestMessageSource source;

    @GetMapping("/send/{id}")
    public String send(@PathVariable("id") Integer id) {
        boolean g = source.testOutputMessageChannel().send(MessageBuilder.withPayload(("go" + id)).build());
        return String.valueOf(g);
    }
}
